package jhub.text;

import java.text.MessageFormat;
import java.text.ParseException;

import jhub.DCProtocol;
import jhub.text.Command;
import jhub.text.DCRawCommand;

public class VersionMessage extends DCRawCommand {
    
    public static VersionMessage getInstance(String version) throws ParseException{
        return new VersionMessage(MessageFormat.format(DCProtocol.VERSION_FORMAT,version));
    }
        
    private String version;
    
    public VersionMessage(String command) throws ParseException {
        super(command);
        parse();
    }
    
    private void parse() throws ParseException{
        Object[] o = new MessageFormat(DCProtocol.VERSION_FORMAT).parse(command.toString());
        setVersion(o[0].toString());
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }
    
}
